<template>
	<view>
		<zy-title></zy-title>
		<view class="zy-page-padding">
			<view class="zy-title-bar-title zy-mt-lg"> 设置 </view>
			<zy-cell-item label="隐私设置" @click="toPrivacy"></zy-cell-item>
			<zy-cell-item label="修改密码" @click="toPassword"></zy-cell-item>
			<zy-cell-item label="联系客服" @click="onService"></zy-cell-item>
			<zy-cell-item label="关于TeAi" :content="version" :arrow="false"></zy-cell-item>
			<zy-cell-item label="账号设置" @click="toAccount"></zy-cell-item>
			<zy-cell-item label="个性化推送" :arrow="false">
				<switch slot="right-icon" :checked="pushChecked" @change="onPushChange"></switch>
			</zy-cell-item>
			
			<zy-button class="zy-mt-100 zy-mh-lg" content="退出登录" @click="onLogout"></zy-button>
		</view>
	</view>
</template>

<script>
	import LoginUtil from '@/main/common/LoginUtil.js';
	import RouteUtil from '@/main/common/RouteUtil.js';
    import CacheUtil from '@/main/common/CacheUtil';
	export default {
		data() {
			return {
				pushChecked: false,
				version: '',
			}
		},
		onShow() {
			this.getPushChecked();
			this.getVersion();
		},
		methods: {
			toPrivacy(){
				RouteUtil.toSetPrivacy()
			},
			toPassword(){
				RouteUtil.toUpdatePassword()
			},
			onService() {
				uni.showModal({
					title: '客服',
					content: `客服QQ：2778027813 工作时间9：00-18：00`
				})
			},
			toAccount() {
				RouteUtil.toAccount()
			},
			onAgreement() {
				RouteUtil.toAgreement()
			},
			onPrivacy() {
				RouteUtil.toPrivacy()
			},
			onPushChange(event) {
				CacheUtil.setSettingPush(event.detail.value)
			},
			getPushChecked() {
				let checked = CacheUtil.getSettingPush();
				if (checked) {
					this.pushChecked = checked;
				}
			},
			getVersion() {
				// #ifdef APP-PLUS
				plus.runtime.getProperty(plus.runtime.appid, (info) => {
					this.version = 'v' + info.version;
				});
				// #endif
			},
			onLogout() {
				LoginUtil.logout()
			},
			
		}
	}
</script>

<style lang="scss" scoped>

</style>